﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.OleDb;
using System.Data;
using System.Configuration;

namespace Catch.AccessCheck
{
    public class CheckMessage
    {
        private readonly string conn = ConfigurationManager.ConnectionStrings["ConnString"].ConnectionString;
        public DataSet GetDataSet()
        {
            DataSet ds = new DataSet();

            OleDbConnection aConnection = new OleDbConnection(conn);

            //创建command对象并保存sql查询语句     
            OleDbCommand aCommand = new OleDbCommand("select   *   from   db1", aConnection);
            try
            {
                aConnection.Open();

                //创建datareader   对象来连接到表单     
                OleDbDataReader aReader = aCommand.ExecuteReader();
                //   Console.WriteLine("This   is   the   returned   data   from   emp_test   table");     

                //循环遍历数据库     
                while (aReader.Read())
                {
                    // Console.WriteLine(aReader.GetInt32(0).ToString());     
                }

                //关闭reader对象     
                aReader.Close();

                //关闭连接,这很重要     
                aConnection.Close();
            }

            //一些通常的异常处理     
            catch (OleDbException e)
            {
                // Console.WriteLine("Error:   {0}",   e.Errors[0].Message);     
            }





            return ds;
        }


    }
}

